/* GLVertexArrayColor.h
 *
 * --
 * Copyright (c) 2012, Christophe Huriaux
 * Distributed under the terms of the MIT license.
 * http://www.opensource.org/licenses/mit-license.php
 * --
 */

#ifndef GLVERTEXARRAYCOLOR_H_
#define GLVERTEXARRAYCOLOR_H_

template <typename Tdata, typename Tcolor>
class GLVertexArrayColor : public GLVertexArray<Tdata>
{
private:
	GLVertexData<Tcolor>* arrayColor;

public:
	GLVertexArrayColor(GLVertexData<Tdata>* data, GLVertexData<Tcolor>* color)
		: GLVertexArray<Tdata>(data), arrayColor(color) {};
	~GLVertexArrayColor() {};

	void setupPointers()
	{
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_COLOR_ARRAY);
		glVertexPointer(GLVertexArray<Tdata>::arrayData->getComponentCount(), GL_FLOAT, 0,
				GLVertexArray<Tdata>::arrayData->getAddress());
		glColorPointer(arrayColor->getComponentCount(), GL_FLOAT, 0,
			arrayColor->getAddress());
	}

	void cleanupPointers()
	{
		glDisableClientState(GL_COLOR_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
	}
};

#endif /* GLVERTEXARRAYCOLOR_H_ */
